//
//  UIImageView+WebImage.swift
//  CLWeiNo
//
//  Created by DDC on 2017/10/16.
//  Copyright © 2017年 DDC. All rights reserved.
//

import SDWebImage

// MARK: - 用户头像图片下载的网络方法封装
extension UIImageView {
    
    func cll_sdWebImage(urlString:String?,placeholderImage:UIImage?,isHeadarIcon:Bool = false) {
        
        guard
            let urlString = urlString,
            let url = URL(string: urlString) else {
            
            image = placeholderImage
            return
        }
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) {[weak self] (image, _, _, _) in
            // 如果是用户头像,显示圆角头像
            if isHeadarIcon{
                self?.image = image?.cll_avatarImage(image: image!, size: (self?.bounds.size)!, backColor: UIColor.white)
            }
        }
    }
    
    
}
